May numbers with a decimal point be input? Yes
May negative numbers be input? Yes
Sometimes there are mistakes in the data. If a group of characters is read that can not be converted into a number, QBasic assigns a 0 to the variable. Here is a file (say that it is called ERRR.DAT) that is supposed to be a file of integers.
12.5 error 10.9
The second line does not contain a proper number. Say that this program was run with this file:
OPEN "ERRR.DAT" FOR INPUT AS #1 ' Open the file for INPUT INPUT #1, NUM ' Read in the first number PRINT NUM ' Print out the first number INPUT #1, NUM ' Read in the second number PRINT NUM ' Print out the second number INPUT #1, NUM ' Read in the third number PRINT NUM ' Print out the third number END
When this program is run, it prints out:
12.5 0 10.9
It can be difficult to catch an error like this.
Why was "0" printed on the second line of output?